<?php

/**
 * Adminhtml grid item renderer
 *
 * @category   VES
 * @package    VES_Vendors
 * @author     Vnecoms Team <support@vnecoms.com>
 */

class VES_VendorsProduct_Block_Widget_Grid_Column_Renderer_Actions
    extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
{
	/**
     * Renders grid column
     *
     * @param   Varien_Object $row
     * @return  string
     */
    
    /*lie 一审二审三审和pending不能编辑，不显示action选项*/
    public function render(Varien_Object $row)
    {
        $text = parent::render($row);
        $value = $row->getData('approval');
		$sku  = $row->getData('sku');
		if($this->isInPromotion($sku))
		{
			
			return '<span class="status_green">'.Mage::helper('catalog')->__('In Promotion').'</span>';
		}
        switch ($value)
        {
        	case VES_VendorsProduct_Model_Source_Approval::STATUS_PENDING:
        		return false;
        		break;
    		case VES_VendorsProduct_Model_Source_Approval::STATUS_1STAPPROVED:
    		    return false;
    		    break;
		    case VES_VendorsProduct_Model_Source_Approval::STATUS_2NDAPPROVED:
		        return false;
		        break;
	        case VES_VendorsProduct_Model_Source_Approval::STATUS_3RDAPPROVED:
	            return false;
	            break;
	        default :
                return '<span class="status_yellow"><a href="' .$this->getUrl('*/*/edit', array(
                    'store'=>$this->getRequest()->getParam('store'),
                    'id'=>$row->getId())
                    ) . '">' . Mage::helper('catalog')->__('Edit') .'</a></span>';
	            break;
        }
    }
	
	
	/*是否是参加活动的产品*/
	protected function isInPromotion($sku)
	{
		$pro = Mage::getModel('promoteevents/product')->getCollection()
					 ->addFieldToFilter('product_sku',$sku)
					 ->getFirstItem();
		if($pro->getData()){
			return true;
		}else{
			return false;
		}
	}
	
}
